import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutterlib/common/style/quhui_style.dart';

class QuhuiImageWidget extends StatelessWidget {
  final String image;
  final VoidCallback onPressed;
  final double width;
  final double height;
  final EdgeInsetsGeometry padding;

  QuhuiImageWidget(
      {this.image,
      this.onPressed,
      this.width = 120,
      this.height = 72,
      this.padding});

  @override
  Widget build(BuildContext context) {
    return ClipRRect(
      borderRadius: BorderRadius.all(Radius.circular(5.0)),
      child: Stack(children: <Widget>[
        CachedNetworkImage(
          width: width,
          height: height,
          fit: BoxFit.cover,
          imageUrl: image,
          placeholder: (BuildContext context, String url){
            return Container(
                width: width,
                height: height,
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(5.0),
                    image: DecorationImage(
                        image: AssetImage(R.DEFAULT_IMAGE)
                    )
                )
            );


          },
        ),
      ]),
    );
//      ClipOval(
//        child: CachedNetworkImage(
//          imageUrl: imageUrl,
//          width: width,
//          height: height,
//          fit: BoxFit.fitHeight,
//        ),
//      );
//
//
//
//      Container(
//      decoration: BoxDecoration(
//          color: Colors.yellow,
//          borderRadius: BorderRadius.all(Radius.circular(18))),
//      child:
//        FadeInImage(
//          placeholder: AssetImage(
//            QuhuiICons.DEFAULT_IMAGE,
//          ),
//          image: NetworkImage(image),
//          //预览图
//          fit: BoxFit.fitWidth,
//          width: width,
//          height: height,
//        ),
//    );
  }
}
